import { WebManageConst } from "src/consts/web_manage_const";
import { PopupName } from "src/consts/popup_const";
import * as Api from 'src/api/net';

const state: any = {} as any;
// StateIniter.init(state, 'demo');

state.idArr = []
// vuex

/** 更新数据的 */
const mutations = {
    [WebManageConst.CommithWebMReset](state: any, data: any): void {
        console.log("webM_ReSet_Panel data update", data);
        state.idArr = data
        WLLib.panel(PopupName.WebM_ReSet_Panel);
    },
}

//异步处理
const actions = {
    [WebManageConst.DispatchWebMReset](context: VuexData, data?: any): void {
        Api.AjaxPost(Config.ajaxUrl + "/website/editpassword.do", data, (res: any) => {
            if (data.lastFlag) {
                WLMessage("批量修改密码成功", "success")
                let senData: any = {}
                senData["curr_page"] = WLStore().state.webManage.curr_page
                senData["page_size"] = WLStore().state.webManage.page_size
                WLDispatch(WebManageConst.DispatchWebMList, senData);
                WLLib.panel(PopupName.WebM_ReSet_Panel).close();
            }
        })
    },
}

export default {
    state,
    mutations,
    actions
}